<?php

class CurrencyActionForm extends ActionForm
{

    function CurrencyActionForm()
    {
        parent::ActionForm();
    }

    function outCurrency ($name, $currency)
    {
        print $this->currencyAsStr($this->container[$name], $currency);
    }

    function currencyAsStr ($amount, $currency)
    {
        if ($amount < 0)
        {
            $amount *= -1;
            $neg        = '-';
        }
        $dec = round($amount,2);
        $int = (int) $dec;
        $dec = round(($dec - $int)*100,0);
        if ($dec == 0)
        {
            $dec='00';
        }
        elseif ($dec<10)
        {
            $dec='0'.$dec;
        }
        if ($currency)
        {
            return $neg.($int.','.$dec).' '.$currency;
        }
        else
        {
            return $neg.($int.','.$dec);
        }
    }

}

?>